package com.qf.service.impl;

import com.qf.dao.ChoiceQuestionDao;
import com.qf.dao.FillQuestionDao;
import com.qf.dao.JudgeQuestionDao;
import com.qf.entity.TbChoiceQuestion;
import com.qf.entity.TbFillQuestion;
import com.qf.entity.TbJudgeQuestion;
import com.qf.service.QuestionService;
import com.qf.utils.ResultMsg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class QuestionServiceImpl implements QuestionService {

    @Autowired(required = false)
    ChoiceQuestionDao choiceQuestionDao;

    @Autowired(required = false)
    JudgeQuestionDao judgeQuestionDao;

    @Autowired(required = false)
    FillQuestionDao fillQuestionDao;

    @Autowired(required = false)
    ResultMsg resultMsg;
    /**
     * 根据试卷编号查询所有题
     * @param testpaperId
     * @return
     */
    @Override
    public ResultMsg findByIdAndType(Integer testpaperId) {
        List<TbChoiceQuestion> byIdAndType1 = choiceQuestionDao.findByIdAndType(testpaperId);   //所有选择题
        List<TbJudgeQuestion> byIdAndType2 = judgeQuestionDao.findByIdAndType(testpaperId);     //所有判断题
        List<TbFillQuestion> byIdAndType3 = fillQuestionDao.findByIdAndType(testpaperId);       //所有填空题
        Map<String, Object> map = new HashMap<>();
        map.put("a",byIdAndType1);
        map.put("b",byIdAndType2);
        map.put("c",byIdAndType3);
        return resultMsg.success(map);
    }
}
